/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.hogent.iii.project.guigameroom;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author jef donders
 */
public class ChatPanel extends JPanel implements ActionListener {

    private JButton knop;
    private JScrollPane jScrollPane1;
    private JTextField textField;
    private JTextArea textArea;
    
    public ChatPanel() {
        initComponents();
    }

    
    private void initComponents() {
        
        jScrollPane1 = new JScrollPane();
        textArea = new JTextArea();//JTextPane();
        
        textField = new JTextField();
        jScrollPane1.setViewportView(textArea);

        textField.addActionListener(this);
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(textField, 0, 390, Short.MAX_VALUE)
                .addComponent(jScrollPane1, 0, 502, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, 0, 100,Short.MAX_VALUE)
                .addComponent(textField, 25, 25, 25))
        );
    }
    
    public void printText(String text){
        
        textArea.append(text);
    }

    public void actionPerformed(ActionEvent e) {
        printText(textField.getText() + "\n");
        textField.setText("");
    }
    
    
}
